/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Data;

import java.awt.geom.Rectangle2D;

/**
 *计算符号的大小。
 * @author Administrator
 */
public class SymbolSize {
    
    private static final double minA1=6140;//1:2000万
    private static final double minA2=8265;//1:1400万
    private static final double minA3=11800;//1:900万
    
    private static final double minG1=2950;//1:2000万
    private static final double minG2=4250;//1:2000万
    private static final double minG3=6610;//1:2000万
    
    private static final double minW=2600;//柱状图的最小宽度；
    
    private static String scale="1:20000000";
    private static SymbolEnum type=SymbolEnum.Art;
    
    private static MethodEnum method=MethodEnum.ratioSqrt2;
    public void setScale(String scale){
        SymbolSize.scale=scale; 
    }
    
    public void setType(SymbolEnum type){
        SymbolSize.type=type;
    }
    
    public void setType(MethodEnum method){
        SymbolSize.method=method;
    }
    
    public double getMinW(){
        return SymbolSize.minW;
    }
    
    public static Rectangle2D getSymbolSize(double minVal,double val,double cx,double cy){
        double d=0;
        double time=0;
        double minV=0;
        switch(method){
            case ratio:
                time=val/minVal;
                break;
            case ratio2:
                time=Math.pow(val/minVal, 2);
                break;
            case ratioSqrt:
                time=Math.sqrt(val/minVal);
                break;
            case ratioSqrt2:
                time=Math.sqrt(Math.sqrt(val/minVal));
                break;
        }
        switch(type){
            case Art:
                switch(scale){
                    case "1:20000000":
                        minV=minA1;
                        break;
                    case "1:14000000":
                        minV=minA2;
                        break;
                    case "1:9000000":
                        minV=minA3;
                        break;
                }
                break;
            case Geo:
                switch(scale){
                    case "1:20000000":
                        minV=minG1;
                        break;
                    case "1:14000000":
                        minV=minG2;
                        break;
                    case "1:9000000":
                        minV=minG3;
                        break;
                }
                break;
        }
        d=time*minV;
        return new Rectangle2D.Double(cx-d/2,cy-d/2,d,d);
    }
    
    public static double getStep(){//获取条形图的间距值
        return 2600;
    }
}
